package kg.aibek.projecteuler.p10;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Problem18 {
	int total = 0;
	int rows = 15;
	List<List<Integer>> tree = new ArrayList<List<Integer>>(15);

	public void solve() {
		Scanner scan = new Scanner(System.in);

		for (int i = 0; i < rows; i++) {
			String s = scan.nextLine();
			tree.add(getList(s));
		}

		getSum(0, 0, 0);
		System.out.println(total);
	}

	private List<Integer> getList(String s) {
		String[] array = s.split(" ");
		List<Integer> list = new ArrayList<Integer>(array.length);
		for (int i = 0; i < array.length; i++) {
			list.add(new Integer(array[i]));
		}
		return list;
	}

	private void getSum(int i, int j, int sum) {
		if (i < rows) {
			List<Integer> list = tree.get(i);
			sum += list.get(j);

			total = Math.max(sum, total);

			getSum(i + 1, j, sum);
			getSum(i + 1, j + 1, sum);
		}
	}

	public static void main(String[] args) {
		Problem18 p = new Problem18();
		p.solve();
	}
}
